﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BiffenGUI.BiffenService;

namespace BiffenGUI
{
    public partial class frmAdmin : Form
    {
        private BiffenServiceClient service = null;
        private frmLogin parent = null;
        
        public frmAdmin()
        {
            InitializeComponent();
            service = new BiffenServiceClient();
        }

        public void SetReferances(frmLogin frmLogin, BiffenServiceClient svc)
        {
            parent = frmLogin;
            this.Owner = parent;
            service = svc;

            ucAddBooking.SetServiceReferance(service);
            ucMovies.SetServiceReferance(service);
            ucBookings.SetServiceReferance(service);
            ucPlanShowings.SetServiceReferance(service);
        }
        
        private void tabMenu_TabIndexChanged(object sender, EventArgs e)
        {
            switch (tabMenu.SelectedIndex)
            {
                case 0:
                    break;
                case 1: 
                    ucBookings.SetFocus();
                    break;
                case 2:
                    break;
                case 3:
                    break;
                case 4:
                    break;


                default:
                    break;
            }
        }

        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason != CloseReason.FormOwnerClosing)
            {
                e.Cancel = true;
                HideForm();
            }
        }

        private void ucPlanShowings_Load(object sender, EventArgs e)
        {
            ucPlanShowings.LoadCombo();
        }

        private void bKillSwitch_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Sikker på at du vil lukke programmet?", "Afslut?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                parent.KillForm();
            }
        }

        private void bLogout_Click(object sender, EventArgs e)
        {
            HideForm();
        }

        private void HideForm()
        {
            parent.Enabled = true;
            parent.ClearFields();
            parent.Focus();
            this.Hide();
        }
        
    }
}
